package com.elective.courseselect.serviceUtils;

import com.elective.courseselect.entity.UserEntity;
import com.elective.courseselect.service.*;
import com.elective.status.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author lee
 * @date 2021年10月24日 1:59
 */
@Component
public class UserUtils {

    public static UserUtils userUtils;


    @Autowired
    UserService userService;

    @Autowired
    CourseService courseService;

    @Autowired
    CourseCharacterService courseCharacterService;

    @Autowired
    CharacterService characterService;

    @Autowired
    CommentService commentService;

    @Autowired
    CommentingService commentingService;

    @Autowired
    CourseQuestionnaireService courseQuestionnaireService;

    @Autowired
    QuestionnaireService questionnaireService;

    @Autowired
    StudentCourseService studentCourseService;

    public static CourseUtils courseUtils;

    @PostConstruct
    public void init(){
        userUtils=this;   //必需
        userUtils.userService=this.userService;
        userUtils.courseService=this.courseService;
        userUtils.courseCharacterService=this.courseCharacterService;
        userUtils.commentService=this.commentService;
        userUtils.commentingService=this.commentingService;
        userUtils.courseQuestionnaireService=this.courseQuestionnaireService;
        userUtils.questionnaireService=this.questionnaireService;
        userUtils.studentCourseService=this.studentCourseService;
    }


    /**
     * 判断是否被禁用
     * @author Lee
     * @date 2021/10/24 2:02
     * @param userId
     * @return java.lang.Boolean
     */
    public static Boolean isAbandon(Integer userId) {
        UserEntity user = userUtils.userService.getById(userId);
        if (null == user || null == user.getState() || StatusCode.NORMAL != user.getState()) {
            return true;
        }else{
            return false;
        }
    }

}
